package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;

import java.util.Objects;

/**
 * @author: wufeng
 * @date: 2018/12/6 21:09
 * @desrcption: 删除标记枚举类
 */
public enum DelEnum {

    /**
     * 删除标记枚举
     * 负责人数据：-1：表示该数据为前负责人
     * 子表单数据：0：正常；1：彻底删除；4：主表删除，对子表单数据删除
     */
    BEFORE_DELETE(-1, "enum.del.memo.before_delete"),
    NORMAL(0, "enum.del.memo.normal"),
    DELETE(1, "enum.del.memo.delete"),
    APPROVE_STATUS(2, "enum.del.memo.approve_status"),
    REMOVE_COMPLETELY(3, "enum.del.memo.remove_completely"),
    DELETE_SUBFORM(4, "enum.del.memo.delete_subform"),
    INVALID(5, "enum.del.memo.invalid"),
    /**
     * 拒绝或者撤回
     */
    APPROVE_FAILED(6, "enum.del.memo.approve_failed"),

    ;

    private Integer del;

    private String memo;

    DelEnum(Integer del, String memo){
        this.del = del;
        this.memo = memo;
    }

    public Integer getDel() {
        return del;
    }

    public void setDel(Integer del) {
        this.del = del;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public static DelEnum getByDel(Integer del) {
        for (DelEnum value : values()) {
            if (Objects.equals(value.getDel(), del)) {
                return value;
            }
        }
        return null;
    }
}
